package cn.tedu.icop.order.dao.repository.impl;

import cn.tedu.icop.order.constant.OrderStatusConstant;
import cn.tedu.icop.order.dao.mapper.OrderFailMapper;
import cn.tedu.icop.order.dao.mapper.OrderSuccessMapper;
import cn.tedu.icop.order.dao.repository.OrderRepository;
import cn.tedu.icop.order.pojo.po.ChargingBillFailPO;
import cn.tedu.icop.order.pojo.po.ChargingBillSuccessPO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository("orderRepository")
public class OrderRepositoryImpl implements OrderRepository {
    @Autowired
    private OrderSuccessMapper orderSuccessMapper;
    @Autowired
    private OrderFailMapper orderFailMapper;

    @Override
    public Boolean saveFailOrder(ChargingBillFailPO newChargingBillFailPO) {
        orderFailMapper.insert(newChargingBillFailPO);
        return true;
    }

    @Override
    public ChargingBillSuccessPO selectSuccessOrderByOrderNo(String orderNo) {
        return orderSuccessMapper.selectOne(
                new QueryWrapper<ChargingBillSuccessPO>()
                        .eq("bill_id",orderNo));
    }

    @Override
    public ChargingBillFailPO selectFailOrderByOrderNo(String orderNo) {
        return orderFailMapper.selectOne(
                new QueryWrapper<ChargingBillFailPO>()
                        .eq("bill_id",orderNo));
    }

    @Override
    public Boolean saveSuccessOrder(ChargingBillSuccessPO newChargingBillSuccessPO) {
        orderSuccessMapper.insert(newChargingBillSuccessPO);
        return true;
    }
}
